---
sidebar_class_name: hidden
---

# Plan and execute

:::info Compatibility
This agent currently only supports Chat Models.
:::

Plan and execute agents accomplish an objective by first planning what to do, then executing the sub tasks. This idea is largely inspired by [BabyAGI](https://github.com/yoheinakajima/babyagi) and then the ["Plan-and-Solve" paper](https://arxiv.org/abs/2305.04091).

The planning is almost always done by an LLM.

The execution is usually done by a separate agent (equipped with tools).

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/agents/plan_and_execute.ts";

This agent uses a two step process:

1. First, the agent uses an LLM to create a plan to answer the query with clear steps.
2. Once it has a plan, it uses an embedded traditional Action Agent to solve each step.

The idea is that the planning step keeps the LLM more "on track" by breaking up a larger task into simpler subtasks.
However, this method requires more individual LLM queries and has higher latency compared to Action Agents.

# With `PlanAndExecuteAgentExecutor`

:::info
This is an experimental chain and is not recommended for production use yet.
:::

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/openai
```

<CodeBlock language="typescript">{Example}</CodeBlock>
